package com.soilflow.web.controller.soilflow;


import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.dto.LandProtocolEnrollDto;
import com.soilflow.common.domain.vo.LandProtocolEnrollVo;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.info.service.LandProtocolEnrollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 转让协议Controller
 * 
 * @author relief
 * @date 2022-10-19
 */
@RestController
@RequestMapping("/land/protocol_enroll")
public class ReliefProtocolEnrollController extends BaseController
{
    @Autowired
    private LandProtocolEnrollService landProtocolEnrollService;

    /**
     * 查询转让协议列表
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol_enroll:list')")
    @GetMapping("/list")
    public TableDataInfo list(LandProtocolEnrollDto landProtocolEnroll)
    {
        startPage();
        List<LandProtocolEnrollVo> list = landProtocolEnrollService.selectLandProtocolEnrollList(landProtocolEnroll);
        return getDataTable(list);
    }



    /**
     * 查询转让协议下拉列表
     */
    @GetMapping("/all")
    public AjaxResult listAll(LandProtocolEnrollDto landProtocolEnroll)
    {
        landProtocolEnroll.setPageSize(null);
        List<LandProtocolEnrollVo> list = landProtocolEnrollService.selectLandProtocolEnrollList(landProtocolEnroll);
        return AjaxResult.success(list);
    }

    /**
     * 获取转让协议详细信息
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol_enroll:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getProtocolEnroll(@PathVariable("id") Long id)
    {
        return AjaxResult.success(landProtocolEnrollService.selectLandProtocolEnrollById(id));
    }

    /**
     * 新增转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol_enroll:add')")
    @Log(title = "转让协议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LandProtocolEnrollDto landProtocolEnroll)
    {
        return toAjax(landProtocolEnrollService.insertLandProtocolEnroll(landProtocolEnroll));
    }

    /**
     * 修改转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol_enroll:edit')")
    @Log(title = "转让协议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LandProtocolEnrollDto landProtocolEnroll)
    {
        return AjaxResult.success(landProtocolEnrollService.updateLandProtocolEnroll(landProtocolEnroll));
    }

    /**
     * 删除转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol_enroll:remove')")
    @Log(title = "转让协议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable  List<Long> ids)
    {
        return toAjax(landProtocolEnrollService.removeByIds(ids));
    }




}